<html>
<head><meta charset="utf-8"><title>Attributes in elements of array and args · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Attributes.20in.20elements.20of.20array.20and.20args.html">Attributes in elements of array and args</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="185419034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Attributes%20in%20elements%20of%20array%20and%20args/near/185419034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Attributes.20in.20elements.20of.20array.20and.20args.html#185419034">(Jan 12 2020 at 04:59)</a>:</h4>
<p>While looking at <a href="https://github.com/rust-analyzer/rust-analyzer/issues/2801" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/2801">#2801</a>, <a href="https://github.com/rust-analyzer/rust-analyzer/issues/2783" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/2783">#2783</a>,<a href="https://github.com/rust-analyzer/rust-analyzer/issues/2781" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/2781">#2781</a>, I just wonder what is the proper place to insert the Attr node for these element ?Some element could be a simple literal, I don't know it is okay to insert in.</p>



<a name="185429982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Attributes%20in%20elements%20of%20array%20and%20args/near/185429982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Attributes.20in.20elements.20of.20array.20and.20args.html#185429982">(Jan 12 2020 at 11:14)</a>:</h4>
<p>I think we already account for attributes in literal expressions:</p>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="w"> </span><span class="n">ast</span>::<span class="n">Literal</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">token</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">SyntaxToken</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="p">.</span><span class="n">syntax</span><span class="p">()</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">children_with_tokens</span><span class="p">()</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">find</span><span class="p">(</span><span class="o">|</span><span class="n">e</span><span class="o">|</span><span class="w"> </span><span class="n">e</span><span class="p">.</span><span class="n">kind</span><span class="p">()</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">ATTR</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="o">!</span><span class="n">e</span><span class="p">.</span><span class="n">kind</span><span class="p">().</span><span class="n">is_trivia</span><span class="p">())</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">and_then</span><span class="p">(</span><span class="o">|</span><span class="n">e</span><span class="o">|</span><span class="w"> </span><span class="n">e</span><span class="p">.</span><span class="n">into_token</span><span class="p">())</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">unwrap</span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="185429983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Attributes%20in%20elements%20of%20array%20and%20args/near/185429983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Attributes.20in.20elements.20of.20array.20and.20args.html#185429983">(Jan 12 2020 at 11:14)</a>:</h4>
<p>so yeah, it's ok</p>



<a name="185430258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Attributes%20in%20elements%20of%20array%20and%20args/near/185430258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Attributes.20in.20elements.20of.20array.20and.20args.html#185430258">(Jan 12 2020 at 11:22)</a>:</h4>
<p>Nice!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>